package com.gitee.sidihuo.utils.util;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.parser.Feature;

import java.util.List;

public class JsonHelper {

    public static String toJsonString(Object object) {
        return JSONObject.toJSONString(object);
    }

    public static <T> T parseObject(String text, Class<T> clazz) {
        return JSONObject.parseObject(text, clazz);
    }

    public static <T> List<T> parseArray(String text, Class<T> clazz) {
        List<T> ts = JSONObject.parseArray(text, clazz);
        return ts;
    }

    public static <T> T parseObject(String text, TypeReference<T> type, Feature... features) {
        return JSONObject.parseObject(text, type, features);
    }

}
